<#include "/common/common.ftl" encoding="UTF-8">
	<link href="${staticUrl}/js/validate/jquery.validate.css" type="text/css" rel="stylesheet" />
	<script src="${staticUrl}/js/validate/jquery.validate.js" type="text/javascript"></script>
	<script src="${staticUrl}/js/validate/messages_cn.js" type="text/javascript"></script>
	<link href="${staticUrl}/css/form.css" type="text/css" rel="stylesheet" />
	
	<#assign action="user">
	<script>
		var treeUrl = "${request.contextPath}/security/dept!deptTree.action";
		$(document).ready(function(){
			//聚焦第一个输入框
			$("#loginName").focus();
			//为inputForm注册validate函数
			$("#inputForm").validate({
				rules: { 
					code: { 
        				required: true, 
        				remote: "user!checkLoginName.action?orgLoginName="+encodeURIComponent('${code?if_exists}')
    			},
          name: "required",
          password: {
    					required: true,
    					minlength:3
    			}, 
    			passwordConfirm: {
    					equalTo:"#password"
    			},
    			email:"email"
				},
				messages: {
					code: {
						remote: "用户登录名已存在"
					},
					passwordConfirm: {
						equalTo: "输入与上面相同的密码"
					}
				}
			});
			$("#deptName").click(function(e){
				previewShow(e);
			});
		});

		function showDetail(id,title){
			$("#deptId").val(id);
			$("#deptName").val(title);
			$("#preview").hide();
		}
	</script>
</head>
<body>
<#include "/common/tree_div.ftl" encoding="UTF-8">
<div class="title"><#if id?exists>修改<#else>创建</#if>用户</div>
<div id="inputContent">
<form id="inputForm" action="${action}!save.action" method="post">
<input type="hidden" name="id" value="${(id)?if_exists}" />
<table class="content">
	<tr>
		<@ftlMacro.inputText name="code" descript="登录名" textShow="${code?if_exists}"/>
	</tr>
	<tr>
		<@ftlMacro.inputText name="name" descript="用户名" textShow="${name?if_exists}"/>
	</tr>
	<tr>
		<@ftlMacro.inputPassword name="password" descript="密码" textShow="${password?if_exists}"/>
	</tr>
	<tr>
		<@ftlMacro.inputPassword name="passwordConfirm" descript="确认密码" textShow="${password?if_exists}"/>
	</tr>
	<tr>
		<@ftlMacro.inputText name="email" descript="邮箱" textShow="${email?if_exists}"/>
	</tr>
	<tr>
		<td class="textLabel">类型:
		</td>
		<td>
		<@ftlMacro.radio name="type" textValues=userTypeMap  checkedValue=type />
		</td>
	</tr>
	<tr>
		<td class="textLabel">部门:</td>
		<td>
			<input type="hidden" name='dept.id' id="deptId" value="${(dept.id)?if_exists}"/>
			<input type="text" class="divshow" name="dept.name" id="deptName" value="${(dept.name)?if_exists}" />
		</td>
	</tr>
	<tr>
		<@ftlMacro.inputText name="orderNum" descript="顺序" textShow="${orderNum?if_exists}"/>
	</tr>
	<tr>
		<td class="textLabel">角色:</td>
		<td>
			<div style="word-break:break-all;width:500px;height:30px overflow:auto; ">
				<@ftlMacro.checkboxDataSource name="checkedAuthorityIds" textValues=allAuthorities checkedValues=checkedAuthorityIds labelProperty="displayName"/>
			</div>
		</td>
	</tr>
	<tr class="button">
		<td colspan="2">
			<input type="submit" value="提交" />&nbsp; 
			<input type="button" value="取消" onclick="history.back()"/>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		</td>
	</tr>
</table>
</form>
</div>
</body>
</html>